<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>安全教育</title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css" />
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/aui.css">
		<link rel="stylesheet" href="../../css/base.css" />
		<link rel="stylesheet" href="../../css/personal.css">
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<link rel="stylesheet" href="../../css/weui.css">
		<link rel="stylesheet" href="../../css/weui.min.css">
		<style>
			.AuthenticationCousre .mui-table-view-cell > a:not(.mui-btn) .course-img {
				display: block;
				width: 136px;
				max-width: 136px;
				height: 84px;
				background-image: url(../../image/course_placehoder.png);
				background-size: 136px 84px;
			}
			.weui_mask {
				position: fixed;
				z-index: 998;
				top: 0;
				right: 0;
				bottom: 0;
				left: 0;
			}
			.weui_dialog {
				z-index: 999;
			}
			.borderLine {
				border-top: 1px solid #DEDEDE;
			}
		</style>
	</head>
	<body>
		<div id="main"  class="borderLine AuthenticationCousre" >
			<ul id="list_id" class="mui-table-view" ></ul>
			<div class="noSign"   id="noData"  hidden="hidden">
				<img src="../../image/icon_img.png" width="60%">
				<p class="font16 top_15 base_dark_grey" >
					暂无数据
				</p>
			</div>
			<div class="loadFailure"  id="noNet" hidden="hidden">
				<img src="../../image/icon_img01.png" width="60%">
				<p class="" >
					数据加载失败
				</p>
				<p>
					请检查您的网络
				</p>
				<button type="button" class="mui-btn mui-btn-outlined" onclick="RefreshData()">
					重新加载
				</button>
			</div>
			<div class="weui_dialog_confirm" id="TestCodeAlert" style="display: none">
				<div class="weui_mask"></div>
				<div class="weui_dialog">
					<div class="weui_dialog_hd">
						<strong class="weui_dialog_title" id="checkNum">当前处于非wifi条件下,是否继续观看视频</strong>
					</div>
					<div class="weui_dialog_bd"></div>
					<div class="weui_dialog_ft">
						<a onclick="TestCodeNo()" href="#" class="weui_btn_dialog default" style="color:#18b4ed">取消</a>
						<a onclick="TestCodeYes()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/getToken.js"></script>
	<script src="../../script/common.js"></script>
	<script type="text/javascript">
		var refreshCount = 0;
		//更新数据条数
		var dataArr = new Array();
		var weightratio = new Array();
		var page = 1;
		var row = 10;
		var chaptername = "";
		var chapterVideourl = "";
		var imgStr = '../../image/course_placehoder.png';
		apiready = function() {
			//			SendBehaviorTrajectoriesNotifi1('0', '安全课程列表页', '133');
			api.setScreenOrientation({
				orientation : 'portrait_up'
			});
			showProgress();
			loadNewData();
			setRefreshHeader();
			setPullUpRefresh();
			api.addEventListener({
       name: 'baiduWebVideoBackNotifi'
          }, function(ret, err) {
         var message = ret.value.message;
         SendBehaviorTrajectoriesNotifi_Authentication('1', '技能课程列表详情页', '136', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title, message);
        });

		}
		function loadNewData() {
			page = 1;
			loadData();
		}

		function loadMoreData() {
			page++;
			loadData();
		}

		//考试编码正确，点击确定按钮,显示选择考核弹窗
		function TestCodeYes() {
			$('#TestCodeAlert').hide();
			//			toPlayVideo(chapterVideourl, chaptername);
			pushToBaiDuPlayer(0, '', chapterVideourl, chaptername);
		}

		//点击考试编码取消按钮，隐藏考试编码弹窗
		function TestCodeNo() {
			$('#TestCodeAlert').hide();
		}

		function loadData() {
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : 52, //集团id
				pags : page,
				rows : row,
				quarter_id : api.pageParam.id,
			};
			cfnetppPOST(url_getsecurityList, param, true, function(data, status) {
				//				alert(JSON.stringify(param))
				//				alert(JSON.stringify(data))
				api.refreshHeaderLoadDone();
				hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						var list = data.data.list;
						var numArr = new Array();
						var imgurl = '';
						if (list != null && list.length > 0) {
							refreshCount = list.length;
							if (list[0].hasOwnProperty('children')) {
								multiplePicturesCache({
									picArr : list[0].children, //包含图片数组
									picKey : 'imgurl'//图片对应的字段
								}, function(imageArr) {
									numArr = imageArr;
									htmlStringWithNameTypeTwo(numArr);
								});
							} else {
								if (list[0].hasOwnProperty('oldname')) {
									imgurl = 'imgurl';
								} else {
									if (list[0].hasOwnProperty('coursename')) {
										imgurl = 'coverimages';
									} else {
										imgurl = 'imgurl';
									}
								}
								multiplePicturesCache({
									picArr : list, //包含图片数组
									picKey : imgurl//图片对应的字段
								}, function(imageArr) {
									numArr = imageArr;
									htmlStringWithName(numArr);
								});
							}
						} else {
							if (page == 1) {
								$('#noData').show();
							} else {
								api.toast({
									msg : '暂无数据',
									duration : 2000,
									location : 'bottom'
								});
							}
							$('#list_id').html('');
						}
					} else {
						if (page == 1) {
							$('#list_id').html('');
							//							alert('333');
							$('#noData').show();
						}
					}
				} else {
					$('#noNet').show();
				}
			});
		}

		function htmlStringWithNameTypeTwo(list) {
			var strhtml = "";
			for (var i = 0; i < list.length; i++) {
				var data = list[i];
				if (data.imgurl == '') {
					imgStr = '../../image/course_placehoder.png';
				} else {
					imgStr = data.imgurl;
				}
				var str = '<li class="mui-table-view-cell mui-media one_cell"  imgurl="' + data.imgurl + '" videourl="' + data.videourl + '"  id="' + data.id + '"   videoname="' + data.chaptername + '" >' + '<a href="javascript:;">' + '<img class="mui-media-object mui-pull-left course-img" src="' + imgStr + '"   onerror="Imgnofind()" />' + '<div class="mui-media-body top-content">' + '<p class="course_title">' + data.chaptername + '</p>' + '</div>' + '<div class="mui-media-body bottom-content">' + '<div class="">'
				// +            '<p class="mui-ellipsis subtitle">'
				//								+'<span class="text_ellipsis" id="sourcefen"> 学分：<span class="course_exam_fen">2'+'</span> </span>'
				//
				//
				//							+'</p>'
				//							+'<p class="mui-ellipsis subtitle">'
				//
				//								+'<span class="text_ellipsis " id="sourcefen"> 介绍：<span class="course_exam_fen">'+isString(data.chapterdesc) +'</span> </span>'
				//
				//							+'</p>'
				+'</div>' + '</div>' + '</a>' + '</li>';
				strhtml = strhtml + str;
			}
			if (page == 1) {
				$('#list_id').html(strhtml);
			} else {
				$('#list_id').append(strhtml);
			}
			setupTapCellClick();
		}

		function htmlStringWithName(list) {
			var strhtml = "";
			var imgurl = "";
			var name = "";
			var info = "";
			var videourl = "";
			for (var i = 0; i < list.length; i++) {
				var data = list[i];
				if (data.hasOwnProperty('oldname')) {
					imgurl = data.imgurl;
					name = data.oldname;
					info = data.chapterdesc;
					videourl = data.url;
				} else {
					if (data.hasOwnProperty('coursename')) {
						imgurl = data.coverimages;
						name = data.coursename;
						info = data.courseinfo;
						videourl = data.url;
					} else {
						imgurl = data.imgurl;
						name = data.title;
						info = data.note;
						videourl = data.url;
					}
				}
				if (data.imgurl == '') {
					imgStr = '../../image/course_placehoder.png';
				} else {
					imgStr = imgurl;
				}
				//				alert(imgStr);
				var str = '<li class="mui-table-view-cell mui-media one_cell"  imgurl="' + imgurl + '"  videourl="' + videourl + '"  id="' + data.id + '"   videoname="' + name + '">' + '<a href="javascript:;">' + '<img class="mui-media-object mui-pull-left course-img" src="' + imgStr + '"   onerror="Imgnofind()"/>' + '<div class="mui-media-body top-content">' + '<p class="course_title">' + name + '</p>' + '</div>' + '<div class="mui-media-body bottom-content">' + '<div class="">'
				// +            '<p class="mui-ellipsis subtitle">'
				//								+'<span class="text_ellipsis" id="sourcefen"> 学分：<span class="course_exam_fen">2'+'</span> </span>'
				//
				//
				//							+'</p>'
				//							+'<p class="mui-ellipsis subtitle">'
				//
				//								+'<span class="text_ellipsis " id="sourcefen"> 介绍：<span class="course_exam_fen">'+isString(info)  +'</span> </span>'
				//
				//							+'</p>'
				+'</div>' + '</div>' + '</a>' + '</li>';
				strhtml = strhtml + str;
			}
			if (page == 1) {
				$('#list_id').html(strhtml);
			} else {
				$('#list_id').append(strhtml);
			}
			setupTapCellClick();
		}

		function setupTapCellClick() {
			SendBehaviorTrajectoriesNotifi1('1', '安全课程列表页', '133', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title);
			$('.one_cell').unbind('click');
			$('.one_cell').click(function() {
				var videourl = $(this).attr('videourl');
				var videoname = $(this).attr('videoname');
				var id = $(this).attr('id');
				var imgurl = $(this).attr('imgurl');
				if (api.pageParam.id < 53) {
					//					api.openWin({useWKWebView:true,
					//						name : 'Student_FreeCourseVideo',
					//						url : '../AuthenticationCousre/Student_FreeCourseVideo.html',
					//						pageParam : {
					//							videourl : videourl,
					//							videoname : videoname
					//						}
					//					});
					chapterVideourl = videourl;
					chaptername = videoname;
					var connectionType = api.connectionType;
					if (connectionType == 'wifi' || connectionType == 'none') {
						//						toPlayVideo(chapterVideourl, chaptername);
						pushToBaiDuPlayer('0', '', chapterVideourl, chaptername);
					} else {
						$('#TestCodeAlert').show();
					}
					//               toPlayVideo(videourl,videoname);
				} else {
					//打开视频课程
					api.openWin({useWKWebView:true,
						name : 'VideoCourseWindow',
						url : '../AuthenticationCousre/VideoCourseWindow.html',
						pageParam : {
							courseid : id,
							coursename : videoname,
							imgurl : imgurl,
							openType : 'security',
							sourceurl : window.location.pathname,
							sourcetitle : document.title,
							quarter_name : api.pageParam.quarter_name
						}
					});
				}
			});
		}

//		function pushToBaiDuPlayer(is_encr, baidu_cloud_id_url, path, title) {
//			//			SendBehaviorTrajectoriesNotifi1('0', '安全课程列表详情页', '134', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title);
//			var message = "学习职业道德" + "《" + title + "》" + "</br>" + api.pageParam.quarter_name + "认证";
//			SendBehaviorTrajectoriesNotifi_Authentication('0', '技能课程列表详情页', '136', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title, message);
//			var videoPath = path;
//			if (is_encr == 1) {//加密
//				videoPath = baidu_cloud_id_url;
//				getVideoToken(function(status, videoToken) {
//					var CFBaiDuVideo = api.require('CFBaiDuVideo');
//					CFBaiDuVideo.initVideo({
//						title : title,
//						path : videoPath,
//						isShowFullScreenBtn : 1,
//						isShowFullScreen : 1,
//						token : videoToken
//					}, function(ret, err) {
//						SendBehaviorTrajectoriesNotifi_Authentication('1', '技能课程列表详情页', '136', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title, message);
//					});
//				});
//			} else {
//				var CFBaiDuVideo = api.require('CFBaiDuVideo');
//				CFBaiDuVideo.initVideo({
//					title : title,
//					path : videoPath,
//					isShowFullScreenBtn : 1,
//					isShowFullScreen : 1,
//					token : ''
//				}, function(ret, err) {
//					SendBehaviorTrajectoriesNotifi_Authentication('1', '技能课程列表详情页', '136', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title, message);
//				});
//			}
//		}
	function pushToBaiDuPlayer(is_encr, baidu_cloud_id_url, path, title){
	
      var message = "学习职业道德" + "《" + title + "》" + "</br>" + api.pageParam.quarter_name + "认证";
	SendBehaviorTrajectoriesNotifi_Authentication('0', '技能课程列表详情页', '136', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title, message);
		if(path != null && path != '' && path.indexOf("http://") < 0 ){
			path = 'http://bos.cfnet.org.cn' + path;
		} 
		var videoPath = path;
 		if (is_encr == 2) {//转码
			videoPath = baidu_cloud_id_url;
			api.openWin({useWKWebView:true,
	 		    name: 'BaiDuWebVideo',
	 		    url: '../Study/BaiDuWebVideo.html',
	 		    pageParam: {
	 		    	title: title,
	 		        url: videoPath,
	 		        token: '',
	 		        vid:'',
	 		        message :message
	 		    },
	 		    slidBackEnabled: false
	 		});
		}else{
			api.openWin({useWKWebView:true,
	 		    name: 'BaiDuWebVideo',
	 		    url: '../Study/BaiDuWebVideo.html',
	 		    pageParam: {
	 		    	title: title,
	 		        url: videoPath,
	 		        token: '',
	 		        vid:'',
	 		        message :message
	 		    },
	 		    slidBackEnabled: false
	 		});
		}
		
	}
		function toPlayVideo(videourl, videoname) {
			SendBehaviorTrajectoriesNotifi1('0', '安全课程列表详情页', '134', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title);
			//	alert(videourl);
			var videoPlayer = api.require('videoPlayer');
			videoPlayer.play({
				path : videourl,
				texts : {
					head : {
						title : videoname
					}
				},
				styles : {
					head : {
						backSize : 24,
						backImg : 'widget://image/vp_back.png',
						setSize : 24,
						setImg : 'widget://image/vp_more.png'
					},
					foot : {
						playSize : 24,
						playImg : 'widget://image/vp_play.png',
						pauseImg : 'widget://image/vp_pause.png',
						nextSize : 24,
						nextImg : 'widget://image/vp_next.png'
					}
				}
			}, function(ret, err) {
				SendBehaviorTrajectoriesNotifi1('1', '安全课程列表详情页', '134', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title);
			});
		}
	</script>
</html>